﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using pos.entity;
using idea.tools;

namespace pos
{
    public partial class settingFrm : Form
    {
        public settingFrm()
        {
            InitializeComponent();
          
        }
        private long m_settingSeqID;
        private void settingFrm_Load(object sender, EventArgs e)
        {
            t_setting t = new t_setting();
            ListViewTool lt = new ListViewTool(listView1);
            t.HeadInsert = lt.insertHead;
            t.RowInsert = lt.insertRow;
          
            t.ExecDataInsertByQuery(null);
            m_settingSeqID = -1;

        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 1)
            {
                t_setting t=new t_setting();
                long s=Convert.ToInt32(listView1.SelectedItems[0].SubItems[0].Text);
                t.seqID = s;
                t.InitBySeqID(s);
                m_settingSeqID = s;
                settingValue.Text = t.value;
                settingName.Text = t.name;
                
                
            }
        }

        private void cmdApply_Click(object sender, EventArgs e)
        {

            t_setting t = new t_setting();
            long s = m_settingSeqID;
            t.seqID = s;
            t.InitBySeqID(s);
            t.value = settingValue.Text;
            t.update();
            if (consts.SettingPara[t.id] != null)
                consts.SettingPara[t.id] = t.value;
            listView1.SelectedItems[0].SubItems[listView1.SelectedItems[0].SubItems.Count - 1].Text = settingValue.Text;

            
        }

       
    }
}
